#!/bin/bash

maxmacs_num=4
#maxmacs_num=all

for f in $*
do
	if [ "$maxmacs_num" = "all" ]; then
		declare -a uniq_macs=`awk -F, '{print $4}' $f |uniq`
		declare -a uniq_essid=`awk -F, '{print $6}' $f |uniq`
	elif [ $maxmacs_num -eq 4 ]; then
		declare -a uniq_macs=`awk -F, '{print $4}' $f |awk -F'|' '{print $1"|"$2"|"$3"|"$4}' |uniq`
		declare -a uniq_essid=`awk -F, '{print $6}' $f |awk -F'|' '{print $1"|"$2"|"$3"|"$4}' |uniq`
	elif [ $maxmacs_num -eq 5 ]; then
		declare -a uniq_macs=`awk -F, '{print $4}' $f |awk -F'|' '{print $1"|"$2"|"$3"|"$4"|"$5}' |uniq`
		declare -a uniq_essid=`awk -F, '{print $6}' $f |awk -F'|' '{print $1"|"$2"|"$3"|"$4"|"$5}' |uniq`
	fi
	iacs=`awk -F, '{print "("$1","$2")"}' $f |uniq`

	echo
	echo ============== $f ================
	num_iacs=`echo $iacs |awk -F" " '{print NF}'`
	echo "Sampled IACs: ($num_iacs)"
	echo $iacs
	echo ----------------------------------
	num_keymacs=`echo ${uniq_macs[@]} |awk -F" " '{print NF}'`
	echo "Unique Strongest $maxmacs_num MACs: ($num_keymacs)"
	for keymacs in ${uniq_macs[@]}
	do 
		echo $keymacs
	done
	echo ----------------------------------
	echo "Unique Strongest $maxmacs_num ESSID: ($num_keymacs)"
	for keyessids in ${uniq_essid[@]}
	do 
		echo $keyessids
	done
done
echo 
